package learn_concurrent._1;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class T20 {
	final static Logger logger = LoggerFactory.getLogger(T20.class);

	public static void main(String[] args) throws InterruptedException {

		Thread t1 = new Thread(() -> {
			logger.debug("洗水壶");
			sleep(1000);
			
			logger.debug("烧开水");
			sleep(5000);
		}, "老王");

		Thread t2 = new Thread(() -> {
			logger.debug("洗茶壶");
			sleep(1000);
			logger.debug("洗茶杯");
			sleep(2000);
			logger.debug("拿茶叶");
			sleep(1000);
			
			try {
				t1.join();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			logger.debug("泡茶");
		}, "小王");

		t1.start();
		t2.start();

	}

	private static void sleep(long time) {
		try {
			Thread.sleep(time);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

}
